x86/p2m: tidy p2m_add_foreign() a little
authorJan Beulich <jbeulich@suse.com>
Fri, 18 Dec 2020 12:28:30 +0000 (13:28 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 18 Dec 2020 12:28:30 +0000 (13:28 +0100)
commit173ae325026bd161ae5eecebda28dab2c7a80668
tree624e273bc4de3e5d7e9cb08c546d07e9f913c5ea
parentf772b592b75d3144174d4c645b916f2718d9cce5
x86/p2m: tidy p2m_add_foreign() a little

Drop a bogus ASSERT() - we don't typically assert incoming domain
pointers to be non-NULL, and there's no particular reason to do so here.

Replace the open-coded DOMID_SELF check by use of
rcu_lock_remote_domain_by_id(), at the same time covering the request
being made with the current domain's actual ID.

Move the "both domains same" check into just the path where it really
is meaningful.

Swap the order of the two puts, such that
- the p2m lock isn't needlessly held across put_page(),
- a separate put_page() on an error path can be avoided,
- they're inverse to the order of the respective gets.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/mm/p2m.c